import axios from 'axios';
import qs from "query-string";

export interface PolicyRecord {
    id: number;
    username: string;
    phone: string;
    status: number;
    create_time:string;
    position_id: number;
    position_name: string;
    position: PositionType[];

}
export interface PositionType {
    id: number;
    admin_id: number;
    position_id: number;
    rule_id: number;
    title:string;


}
export interface PolicyParams extends Partial<PolicyRecord> {
    current: number;
    pageSize: number;
}

export interface BaseInfoModel {
    activityName: string;
    channelType: string;
    promotionTime: string[];
    promoteLink: string;
}
export interface ChannelInfoModel {
    advertisingSource: string;
    advertisingMedia: string;
    keyword: string[];
    pushNotify: boolean;
    advertisingContent: string;
}
export interface positionTree {
    id: number;
    pid: number;
    name: string;
    son: [sonType];
}
export interface sonType {
    id: number;
    pid: number;
    name: string;
}
export type UnitChannelModel = BaseInfoModel & ChannelInfoModel;

export function departmentInfo() {
    return axios.get<positionTree>('/admin/position/tree');
}
export function addDepartments(data:any) {
    return axios.post<any>('/admin/position/add',data);
}
export function deleteDepartment(data:any) {
    return axios.post<any>('/admin/position/del',data);
}
export function treeDataDepartment(id:number) {
console.log(id)
    return axios.get<any>('/admin/position/rule_tree', {
        params: {
          id:id,
        }
    });
}
export function checkedKeysDepartment(data:any) {
    return axios.post<any>('/admin/position/band_rule',data);
}
export function queryUserList(data:any) {
    return axios.get<any>('/admin/admin/list');
}
export function addUserInfo(data:any) {
    return axios.post<any>('/admin/admin/add',data);
}
export function delUserInfo(data:any) {
    return axios.post<any>('/admin/admin/del',data);
}
export function editDepartments(data:any) {
    return axios.post<any>('/admin/position/edit',data);
}

export function changeUserInfo(data:any) {
    return axios.post<any>('/admin/admin/band_position',data);
}


export function addUser(data:any) {
    return axios.post<any>('/admin/admin/add_bind',data);
}